/**
 * 
 */
package com.et114.modules.products;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import com.et114.core.action.BaseDispatchAction;
import com.et114.modules.content.services.CommonContentImpl;
import com.et114.modules.content.services.SliderServiceImpl;
import com.et114.modules.content.vo.CommonContent;
import com.et114.modules.content.vo.CommonType;
import com.et114.modules.content.vo.Slider;
import com.et114.modules.products.cellphone.services.CellPhoneServiceImpl;
import com.et114.modules.products.cellphone.vo.CellPhone;
import com.et114.modules.products.commons.Const;
import com.et114.modules.products.commons.Context;

/*
 * @author guanhw
 */
public class ProsIndex extends BaseDispatchAction {
	public  ActionForward index4View( ActionMapping mapping , ActionForm form ,
			HttpServletRequest request , HttpServletResponse response ) throws Exception {
		long ct = System.currentTimeMillis ( ) ; 
		//loads cell phone top10
		CellPhoneServiceImpl cellPhoneServiceImpl = ( CellPhoneServiceImpl )getBean( Context.PRO_CELLPHONE_SERVICE ) ; 
		List< CellPhone > cptopten  = cellPhoneServiceImpl.getCellPhoneTopTen ( ) ; 
		request.setAttribute ( "cptopten" , cptopten ) ; 

		SliderServiceImpl sss = ( SliderServiceImpl ) getBean( Context.COMMON_SLIDER_SERVICE ) ;
		List< Slider >  sliders = sss.getSlidersCacheModel ( new Slider( ) ) ; 
		request.setAttribute ( "sliders" , sliders ) ; 
		
		CommonType commonType = new CommonType( ) ; 
		commonType.setGlobalKey ( Const.CONTENT_NEWS_TYPE_GLOBAL_NEWS ) ; 
		commonType.setTypeId ( Const.CONTENT_NEWS_TYPE_NEWSCENTER ) ; 		
		CommonContentImpl cci = ( CommonContentImpl )getBean( Context.COMMON_NEWS_SERVICE ) ; 
		List< CommonContent > commonContents = cci.getCommonContentsNpageCacheModel ( commonType ) ;
		request.setAttribute ( "commonContents" , commonContents ) ;
		
		

		commonType.setGlobalKey ( Const.CONTENT_NEWS_TYPE_GLOBAL_FAQ ) ; 
		commonType.setTypeId ( null ) ;
		List< CommonContent > faqs = cci.getCommonContentsNpageCacheModel ( commonType ) ;
		request.setAttribute ( "faqs" , faqs ) ;

		
		logger.info ( "index loads " + ( System.currentTimeMillis ( ) - ct ) ) ; 
		return mapping.findForward ( "prosIndex4View" ) ;
	}

}
